package legumes.shared.domain;

public enum CustomerRole {
	ADMINISTRATOR("Administrateur"), 
	CUSTOMER("Client"), 
	NONE("Aucun");

	private String displayName;

	private CustomerRole(String displayName_) {
		displayName = displayName_;
	}

	public String getDisplayName() {
		return displayName;
	}

	public static CustomerRole fromDisplayName(String displayName_) {
		for (CustomerRole r : values()) {
			if (r.getDisplayName().equals(displayName_)) {
				return r;
			}
		}
		return null;
	}

	public static String[] getDisplayNames() {
		String[] tab = new String[values().length];
		int i = 0;
		for (CustomerRole r : values()) {
			tab[i++] = r.getDisplayName();
		}
		return tab;
	}

	public boolean hasRightToOrder() {
		return !equals(NONE);
	}

	// public static final String ROLE_SEPARATOR = ",";

	// public static List<CustomerRole> parseRoles(String s_) {
	// String[] roleStrs = s_.split(ROLE_SEPARATOR);
	//
	// ArrayList<CustomerRole> roles = new ArrayList<CustomerRole>();
	// for (String roleStr : roleStrs) {
	// CustomerRole role = CustomerRole.valueOf(roleStr.trim());
	// roles.add(role);
	// }
	//
	// return roles;
	// }
	//
	// public static String format(CustomerRole role1, CustomerRole... r_) {
	// StringBuilder sb = new StringBuilder();
	//
	// sb.append(role1.toString());
	//
	// for (CustomerRole r : r_) {
	// sb.append(ROLE_SEPARATOR).append(r.toString());
	// }
	//
	// return sb.toString();
	// }
}
